<template>
  <div class="item">

    <div class="title">
      <el-tag v-if="item.isTop" class="tag" effect="plain" type="danger" size="mini">置顶</el-tag>
      <nuxt-link :to="{name:'node',params:{id:item.node.id}}" class="c-tag" v-text="item.node.title"></nuxt-link>
      <div class="name">
        <nuxt-link :to="{name: 'topic-id',params:{id:item.id}}" v-text="item.title"></nuxt-link>
      </div>
    </div>
    <div class="pieces flex">
      <div class="left flex">
        <UserInfo :user="item.user"/>
        <span class="badge"></span>
        <span class="time" v-text="item.lastReplied"></span>
      </div>
      <div class="right">
        <div class="view"><i class="el-icon-view"></i>{{ item.view }}</div>
        <div class="comment"><i class="el-icon-chat-dot-round"></i>{{ item.reply }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "PostItem",
  props: {
    item: {
      type: Object,
      default: null
    }
  }
}
</script>

<style scoped lang="less">
.item {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;

  &:last-child {
    margin-bottom: 0;
    border-bottom:none;
  }

  .title {
    display: flex;
    margin: 10px auto;
    .c-tag {
      color: #45d1b2;
      background-color: rgb(233, 250, 246);
      font-size: 12px;
      text-align: center;
      display: inline-block;
      border-radius: 2px;
      padding: 2px 5px;
      margin-right: 10px;
    }

    .tag {
      flex: 0;
      margin-right: 10px;
    }

    .name {
      flex: 1;

      a {
        font-size: 16px;
        font-weight: 400;
      }
    }
  }

  .summary {
    line-height: 25px;
    word-break: break-all;
    color: var(--post-color);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    font-size: 14px;
  }

  .pieces {
    margin-top: 10px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .badge {
      background-color: var(--bg);
      width: 3px;
      height: 3px;
      display: inline-block;
      border-radius: 50%;
    }


    .time {
      color: #aaa;
    }

    .view {
      margin-right: 10px;
    }

    .view, .comment {
      color: #aaa;
      font-size: 14px;
      display: inline-block;
      //width: 50px;

      i {
        margin-right: 10px;
      }
    }

    .right {
      flex: 0 0 120px;
    }
  }

}
</style>
